FROM alpine:3.10.1
RUN apk update && apk upgrade && apk add --no-cache nano sudo wget curl \
tree elinks bash shadow procps util-linux coreutils binutils findutils grep && \
wget https://busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/busybox-x86_64 && \
chmod +x busybox-x86_64 && mv busybox-x86_64 bin/busybox1.28
CMD ["/bin/bash"]
FROM alpine.base
RUN apk update && apk upgrade && apk add --no-cache openssh openrc && rc-update add sshd && \
# 設定 OpenSSH
mkdir /run/openrc && touch /run/openrc/softlevel && rc-status &>/dev/null && \
# 建立 sshup
echo '#!/bin/bash' > /usr/bin/sshup && echo -e 'Welcome to Alpine 3.10.1\n' > /etc/motd && \
echo '/etc/init.d/sshd start &>/dev/null && tail -f /dev/null' >> /usr/bin/sshup && chmod +x /usr/bin/sshup && \
# 建立管理者帳號
adduser -s /bin/bash -h /home/user -G wheel -D user && echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
echo -e "userd\nuser\n" | passwd user &>/dev/null && [ "$?" == "0" ] && echo “Add user ok!"
ENTRYPOINT ["/usr/bin/sshup"]
# https://hub.docker.com/_/microsoft-dotnet-core
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore
# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app --no-restore
# final stage/image
FROM mcr.microsoft.com/dotnet/core/runtime:3.1
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "dotnet.dll"]